#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;


class A
{
public:
	A()
	{
		cout << "A called" << endl;
		func();
	}
	~A()
	{
		cout << "A cancel" << endl;
		func();
	}
	virtual void func()
	{
		cout << "A func" << endl;
	}
};

class B : public  A
{
public:
	B()
	{
		cout << "B called" << endl;
		func();
	}
	~B()
	{
		cout << "B cancel" << endl;
		func();
	}
	virtual void  func()
	{
		cout << "B func" << endl;
	}
};

class Decorator
{
public:
	Decorator()
	{
		cout << "I'm before main!" << endl;
	}
	~Decorator()
	{
		cout << "I'm after main!" << endl;
	}
};

Decorator deco;

int main()
{
	A* ptr = new B;
	delete ptr;

	system("pause");
	return 0;
}